package com.whjfxx.terminal.api.valid;

import com.whjfxx.terminal.api.param.ActiveParam;
import com.whjfxx.terminal.exceptions.BizException;
import com.whjfxx.terminal.utils.ValidatorUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.ValidationUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Objects;
import java.util.logging.SimpleFormatter;

/**
 * Created by b.c on 2022/6/20 18:43
 */
public class ActivateValid {

    /**
     * 参数校验
     * @param activeParam
     */
    public static void valid(ActiveParam activeParam) {
        if (Objects.isNull(activeParam)) {
            throw BizException.build("参数错误");
        }
        ValidatorUtil.validate(activeParam);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        try {
            sdf.parse(activeParam.getReq_time());
        } catch (ParseException e) {
            throw BizException.build("激活请求时间参数格式错误");
        }
    }
}
